<!DOCTYPE HTML>
<html>
<head>
   <meta charset="UTF-8" />
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta http-equiv="Access-Control-Allow-Origin" content="*">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
    <title>title</title>
    <script type="text/javascript" src="../../script/s94.js#debug"></script>
    <script type="text/javascript" src="../../script/s94.app.js"></script>
    <!--公共部分-->
    <script type="text/javascript" src="../../script/common.js"></script>
    <link href="../../css/common.css" rel="stylesheet" type="text/css" />
</head>
<style type="text/css">
	.body{font-size: 0.28rem;}
	.body .button{margin: 0.1rem;}
	.title{width: 100%;margin: 0.6rem 0 0.2rem 0;text-align: center;font-size: 0.36rem;font-weight: bold;}
</style>
<body>
	<header class="public">
		<a app href="back" target="_blank"><i ico class="ico-fx-l"></i></a>
		<div class="set-xy full">createNotification模块测试</div>
	</header>
	<div class="body">
		<p class="title">APP中</p>
		
		<div class="button" act="create">创建</div>
		<div class="button" act="close">close</div>
		<div class="button" act="update">更新</div>
		<div class="button" act="update" key="update_p">进度条</div>

	</br></br>
		<div class="button" act="test">测试</div>
		
	</div>
</body>
<script type="text/javascript">
//每个方法传递的参数
var now_id = 0;
var cache_status=true;
var params = {
	create: {title: "标题", content: "撒打发时间到了开房记录数据裂缝宽度是记录房间里的撒娇浪费空间的数量快捷方式老咔叽拉萨看得见", ongoing:true, data: {a:1}},
	music: {title: "music", content: "musicmusicmusic", data: {a:1}},
	close: function(){
		return {id: now_id}
	},
	update_p: function(){
		var p = Math.random();
		return {
			id: now_id,
			progress: p,
			content: "当前进度："+(Math.round(p*1000)/10)+'%'
		}
	},
	update: function(){
		return {
			id: now_id,
			title: "标题",
			content: "内容",
		}
	}
}
$.app(function(){ //APP加载完成后执行回调函数，等效于apicloud的apiready方法
	var md = $.app("createNotification");//等效于api.require("createNotification");
	//所有按钮统一绑定事件
	$('.button[act]').on("click",function(){
		var act = $(this).attr("act"); //获取需要执行的方法名称
		var key = $(this).attr("key"); //获取需要执行的方法名称
		var param = params[(key||act)]; //获取执行的方法需要传递的参数
		switch (typeof(param)) {
			case 'underfind': param = {};break;
			case 'function': param = param();break;
		}
		md[act](param, function(res){
			tips(res.msg);
			$.log(res, act);
			if(!res.status) return;
			switch (act) {
				case "create":{
					if(res.msg=="event"){
						$.log(res, "点击通知");
					}else{
						now_id = res.id;
					}
				}break;
			}
		})
	})

})
</script>
</html>
